<template>
	<page-body>
		<view class="page">
			<view class="flex align-stretch benben-position-layout flex bindBankCard_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex align-center justify-between flex-sub bindBankCard_fd0_0'>
					<view class='flex align-center bindBankCard_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
						data-url="1">
						<text class='fu-iconfont2  bindBankCard_fd0_0_c0_c0'>&#xE794;</text>
					</view>
					<view class='flex align-center'>
						<text class='bindBankCard_fd0_0_c1_c0'>绑定银行卡</text>
					</view>
					<view class='flex align-center bindBankCard_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout bindBankCard_flex_1">
				<view class='flex flex-direction align-stretch bindBankCard_fd1_0'>
					<view class='flex flex-wrap align-center bindBankCard_fd1_0_c0'>
						<text class='bindBankCard_fd1_0_c0_c0'>持卡人姓名</text>
						<benben-input class='flex-sub bindBankCard_fd1_0_c0_c1' type="text" :placeholder="`请输入真实姓名`"
							confirm-type="done" :maxlength="-1"
							placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx"
							v-model="dataBangding.real_name" />
					</view>
					<view class='flex flex-wrap align-center bindBankCard_fd1_0_c0'>
						<text class='bindBankCard_fd1_0_c0_c0'>银行名称</text>
						<benben-input class='flex-sub bindBankCard_fd1_0_c0_c1' type="text" :placeholder="`请输入银行名称`"
							confirm-type="done" :maxlength="-1"
							placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx"
							v-model="dataBangding.bank_name" />
					</view>
					<view class='flex flex-wrap align-center bindBankCard_fd1_0_c0'>
						<text class='bindBankCard_fd1_0_c0_c0'>银行卡号</text>
						<benben-input class='flex-sub bindBankCard_fd1_0_c0_c1' type="text" :placeholder="`请输入银行卡号`"
							confirm-type="done" :maxlength="19"
							placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx"
							v-model="dataBangding.account" />
					</view>
					<view class='flex flex-wrap align-center bindBankCard_fd1_0_c0'>
						<text class='bindBankCard_fd1_0_c0_c0'>开户行</text>
						<benben-input class='flex-sub bindBankCard_fd1_0_c0_c1' type="text" :placeholder="`请输入开户行`"
							confirm-type="done" :maxlength="-1"
							placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx"
							v-model="dataBangding.bank_address" />
					</view>
				</view>
				<view class='flex flex-wrap align-center justify-center bindBankCard_fd1_1'>
					<button class='bindBankCard_fd1_1_c0' @tap.stop="postBankFunc()">提交</button>
				</view>
			</view>

			<!---flex布局flex布局结束-->


		</view>
	</page-body>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},


		data() {
			return {
				"dataBangding": {
					"aid": "",
					"is_default": "",
					"create_time": "",
					"update_time": "",
					"status": "",
					"real_name": "",
					"account": "",
					"qrcode_url": "",
					"bank_name": "",
					"bank_address": "",
					"remark": ""
				},
				"type": "",
				posTtype:false,
			};
		},
		computed: {

		},
		watch: {},
		onLoad(options) {
			let {
				type
			} = options
			if (type !== undefined) this.type = type
			this.getbangdingFunc()
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//绑定银行卡
			async postBankFunc() {
				if (!validate(this.dataBangding.real_name, 'require')) {
					this.$message.info('请输入真实姓名');
					return false;
				}
				if (!validate(this.dataBangding.bank_name, 'require')) {
					this.$message.info('请输入银行名称');
					return false;
				}
				if (!validate(this.dataBangding.account, 'require')) {
					this.$message.info('请输入银行卡号');
					return false;
				}
				if (!validate(this.dataBangding.bank_address, 'require')) {
					this.$message.info('请输入开户行');
					return false;
				}
				//请求方法
				//数据验证
				if(this.posTtype){
					return
				}
				this.posTtype = true
				let data636cc0cc8d6cc = await this.$api.post(global.apiUrls.post64793e01427b6, {
					real_name: this.dataBangding.real_name,
					account_type: '3',
					account: this.dataBangding.account,
					qrcode_url: this.dataBangding.qrcode_url,
					bank_name: this.dataBangding.bank_name,
					bank_address: this.dataBangding.bank_address,
					remark: this.dataBangding.remark
				});

				if (data636cc0cc8d6cc.data.code != 1) {
					this.$message.info(data636cc0cc8d6cc.data.msg);
					this.posTtype = false
					return
				}
				let info636cc0cc8d6cc = data636cc0cc8d6cc.data;


				this.$message.info('银行卡绑定成功');
				setTimeout(() => {
					this.$urouter.navigateBack(1);
				}, 500)
			},
			//获取绑定信息
			async getbangdingFunc() {
				if (this.type == '1') {
					//请求方法
					//数据验证

					let datadataBangding = await this.$api.get(global.apiUrls.post64793f5df043e, {
						account_type: '3'
					});

					if (datadataBangding.data.code != 1) {
						this.$message.info(datadataBangding.data.msg);
						return
					}
					let infodataBangding = datadataBangding.data;
					this.dataBangding = infodataBangding.data

				}
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto;
	}

	.bindBankCard_flex_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.bindBankCard_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333;
	}

	.bindBankCard_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
	}

	.bindBankCard_fd0_0_c0 {
		width: 180rpx;
	}

	.bindBankCard_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
	}

	.bindBankCard_flex_1 {
		padding: 0rpx 0rpx 150rpx 0rpx;
	}

	.bindBankCard_fd1_1_c0 {
		background: var(--benbenbgColor7);
		border-radius: 40rpx 40rpx 40rpx 40rpx;
		font-size: 32rpx;
		color: #fff;
		width: 686rpx;
		height: 80rpx;
		line-height: 80rpx;
		font-weight: 700;
	}

	.bindBankCard_fd1_1 {
		width: 750rpx;
		position: fixed;
		left: 0rpx;
		bottom: calc(40rpx + var(--window-bottom));
	}

	.bindBankCard_fd1_0_c0_c1 {
		font-size: 32rpx;
		font-weight: 400;
		color: #333;
	}

	.bindBankCard_fd1_0_c0_c0 {
		width: 210rpx;
		line-height: 43rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
	}

	.bindBankCard_fd1_0_c0 {
		border-bottom: 1px solid #eee;
		height: 109rpx;
	}

	.bindBankCard_fd1_0 {
		background: var(--benbenbgColor1);
		padding: 0rpx 32rpx 0rpx 32rpx;
		background-size: 100% auto !important;
	}
</style>
